from django.shortcuts import render
from myapp.ser import PicSerializer
from myapp.models import PriceModel
from rest_framework.viewsets import ModelViewSet
from rest_framework.pagination import PageNumberPagination
from rest_framework.filters import SearchFilter
# Create your views here.

class Pag(PageNumberPagination):
    page_size = 5
    max_page_size = 5
    page_size_query_param = 'size'
    page_query_param = 'page'

class PicView(ModelViewSet):
    queryset = PriceModel.objects.all()
    serializer_class = PicSerializer
    lookup_field = 'id'
    lookup_url_kwarg = 'id'

    pagination_class = Pag

    filter_backends = [SearchFilter]
    search_fields=['cate']